﻿using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace TD.Interface.Credits.Effects
{
    internal class Efx_Scale : Effect
    {
        private const float MIN_SCALE = 0.2f;
        private const float MAX_SCALE = 1.2f;
        
        private readonly Random random = new Random();

        private Matrix matrix;
        private float scale;

        public Efx_Scale() :
            base(1000)
        {
            this.matrix = Matrix.Identity;
            this.scale = 1.0f;
        }

        protected override void TriggerEfx()
        {
            float diff = (MAX_SCALE - MIN_SCALE);
            scale = (float)(((random.NextDouble() * 100 * diff / 100)) + MIN_SCALE);

            matrix = Matrix.CreateScale(scale);

            base.TriggerEfx();
        }

        protected override Matrix[] ApplyMatrices()
        {
            return new Matrix[1] { matrix };
        }
    }
}
